import java.util.Scanner;

public class TestException {
    public static void main(String[] args) {
        String name = "admin";
        String password = "123456";
        login(name,password);
    }
    public static void login(String name, String password){
        Scanner sc = new Scanner(System.in);
        while(true){
            System.out.print("请输入用户名：");
            String inputName = sc.nextLine();
            System.out.print("请输入密码：");
            String inputPassword = sc.nextLine();
            if(!inputName.equals(name)){
                throw new NameException("名字不匹配！");
            }
            if(!inputPassword.equals(password)){
                throw new passwordException("密码不匹配！");
            }
            if(inputName.equals(name) && inputPassword.equals(password)){
                System.out.println("登陆成功！");
                break;
            }
        }
    }
}
